package com.sample.thread.bizhall;

import java.util.SplittableRandom;

/**
* 营业厅窗口
* @author  zg
* @date 2021年3月1日
*/
public class BusinessWindowRunnable implements Runnable {

    @Override
    public void run() {
        Integer ticketNum = 0;
        while ((ticketNum = BusinessHall.getSeqNum()) != null) {
            System.out.println("【" + Thread.currentThread().getName() + "】号窗口 - 处理业务号码[" + ticketNum +"]...");
            int randomWait = new SplittableRandom().nextInt(1, 10);
            try {
                Thread.sleep(randomWait * 1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("【" + Thread.currentThread().getName() + "】号窗口 - 处理业务号码[" + ticketNum +"]执行完毕。用时" + randomWait +"秒");
        }
    }

}
